<?php
/**
* Reads the file that was asked to be downloaded
 */

    include_once "conf.php";
    include_once "Properties.cls.php";

    $props = new Properties();
    $props->load(fopen(CONF_LOCATION, "r"));
    $restoreFilesPath = $props->getProperty("restoreFilesPath", './restorefiles');

    $fileName = $restoreFilesPath."/".$_GET['name'];

    header('Content-Description: File Transfer');
    header('Content-type: text/sql');
    header('Content-Disposition: attachment; filename="'.$_GET['name'].'"');
    header('Content-Transfer-Encoding: binary');
    header('Expires: 0');
    header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
    header('Pragma: public');
    header('Content-Length: ' . filesize($fileName));
    

    $fd = fopen($fileName, "r");

    while ( !feof($fd) ) {
    $buf = fread($fd, 32768);
        print $buf;
    }
    fclose($fd);

?>